package utils;

import org.bouncycastle.jce.provider.BouncyCastleProvider;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Security;

public class Hash {
/**
 * @author: dae
 * @email: 675116529@qq.com
 * @phone: 15270029507
 * @DateTime: 2021/12/20 15:16
 * 工具类 用于封装 各种类型的hash算法
 **/

public  static  byte[] SHA256(byte[] data){
    try {
        MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
        messageDigest.update(data);
        return messageDigest.digest();


    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }


    return null;
}
public  static byte[] RIPEMD160(byte[] data) {
                     Security.addProvider(new BouncyCastleProvider());
    try {
        MessageDigest digest = MessageDigest.getInstance("RipeMd160");
        digest.update(data);
        return digest.digest();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
    return null;

}
}
